<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ProcedureAdd</title>
    <link href="../../../webjar/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link rel="stylesheet" media="all" type="text/css" href="CSS/workflow.css" />
</head>
<body>
    <form class="form-horizontal" role="form" style="padding:15px;">
        <div class="form-group">
            <label for="ProgramInfo" class="col-xs-4 control-label">工序信息: </label>
            <div class="col-xs-8">
                <div class="input-group">
                    <input type="text" class="form-control unit" id="ProgramInfo" placeholder="请选择单位" readonly="true">
                    <span class="input-group-btn"><button id="ProgramInfo_Btn" class="btn btn-default" type="button">选择</button> </span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label for="WorkInfo" class="col-xs-4 control-label">工位（组）: </label>
            <div class="col-xs-8">
                <div class="input-group">
                    <input type="text" class="form-control unit" id="WorkInfo" placeholder="请选择单位" readonly="true">
                    <span class="input-group-btn"><button id="WorkInfo_Btn" class="btn btn-default" type="button">选择</button> </span>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label for="Step_Number" class="col-xs-4 control-label">步骤序号：</label>
            <div class="col-xs-8">
                <input type="text" class="form-control" id="Step_Number" placeholder="请输入步骤序号">
            </div>
        </div>

        <div class="form-group" style = "margin-bottom: 0px">
            <div class="col-xs-6" style="text-align:right">
                <button type="button" id="SaveProcedure_Btn" class="btn btn-custom">保存</button>
            </div>
            <div class="col-xs-6" style="text-align:left">
                <button type="button" id="AddProcedure_Cancel_Btn" class="btn btn-custom">取消</button>
            </div>
        </div>
    </form>
<script>
    var index, cof1 = false, cof2 = false;
    $(function(){
        //选择程序按钮
        $('#ProgramInfo_Btn').on('click',function(){
            var url = "SelectProgram.html";
            index = ibcpLayer.ShowDiv(url, '选择程序', '400px', '450px');
            cof1 = true;
        });

        //选择工位（组）按钮
        $('#WorkInfo_Btn').on('click',function(){
           var url = "SelectWork.html";
            index = ibcpLayer.ShowDiv(url,"选择工位（组）", '400px', '450px');
            cof2 = true;
        });

        //确认保存按钮
        $('#SaveProcedure_Btn').on('click', function(){
            var ckResult = CheckEmptyTips();
            if(ckResult == false) return;

            var addObject = getObjectById(ActiveId);
            if(!addObject || addObject.objType != "Task"){
                //添加矩形
                drawRectangleCmd();
            }

            var programdata = [], workdata = [];
            programdata = $('#ProgramInfo').attr('ibcdata').split(",");
            workdata = $('#WorkInfo').attr('ibcdata').split(",");
            var wfprcode = programdata[0];
            var wfprname = programdata[1];
            var wfprversion = programdata[2];
            var wfprid = programdata[3];
            var wfwkcode = workdata[0];
            var wfwkname = workdata[1];
            var wfwkid = workdata[2];
            var wfwktype = workdata[3];
            selectProcedureInfo(wfprcode, wfprname, wfprversion, wfprid, wfwkcode, wfwkname, wfwkid, wfwktype, $('#Step_Number').val());
        });

        //数据非空验证
        function CheckEmptyTips(){
            'use strict';
            var check = true;
            if($('#ProgramInfo_Btn').val() == ""){
                ibcpLayer.ShowTips('请选择工序',$("#ProgramInfo_Btn"));
                check = false;
            }
            if($('#WorkInfo').val() == ""){
                ibcpLayer.ShowTips('请选择工位',$("#WorkInfo_Btn"));
                check = false;
            }
            if(($('#Step_Number').val() == "")){
                ibcpLayer.ShowTips('请键入编号',$('#Step_Number'));
                check = false;
            }
            return check;
        }
    });

</script>
</body>
</html>